﻿using Microsoft.EntityFrameworkCore;
using Prism.Ioc;
using Prism.Regions;
using Prism.Unity;
using System.Configuration;
using System.Data;
using System.Windows;
using XH.SmartParking.Views;
using XH.SmartParking.Views.Pages;
using XH.SmartParking.Views.Pages.Dialogs;
using XH.SmartParking.IService;
using XH.SmartParking.Base;
using XH.SmartParking.ORM;
using XH.SmartParking.Service;

namespace XH.SmartParking
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainView>();
        }

        protected override void InitializeShell(Window shell)
        {
            base.InitializeShell(shell);

            Container.Resolve<IRegionManager>().RegisterViewWithRegion("MainRegion", "DashboardView");
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterDialog<LoginView>();
            containerRegistry.RegisterDialogWindow<DialogWindowEx>();


            // 注册相关的实体
            containerRegistry.RegisterSingleton<DbContext, XHDbContext>();
            containerRegistry.Register<IUserService, UserService>();
            containerRegistry.Register<IMenuService, MenuService>();
            containerRegistry.Register<IRoleService, RoleService>();
            containerRegistry.Register<IDeviceService, DeviceService>();
            containerRegistry.Register<IAutoService, AutoService>();
            containerRegistry.Register<IRechargeService, RechargeSerivce>();
            containerRegistry.Register<IRecordService, RecordService>();
            containerRegistry.Register<IPayService, PayService>();
            containerRegistry.Register<IReportService, ReportService>();


            containerRegistry.RegisterForNavigation<DashboardView>();
            containerRegistry.RegisterForNavigation<MenuManagementView>();
            containerRegistry.RegisterForNavigation<UserManagementView>();
            containerRegistry.RegisterForNavigation<RoleView>();
            containerRegistry.RegisterForNavigation<DeviceView>();
            containerRegistry.RegisterForNavigation<AutoView>();
            containerRegistry.RegisterForNavigation<RechargeView>();
            containerRegistry.RegisterForNavigation<MonitorView>();
            containerRegistry.RegisterForNavigation<OrderView>();
            containerRegistry.RegisterForNavigation<ReportView>();



            containerRegistry.RegisterDialog<ModifyMenuView>();
            containerRegistry.RegisterDialog<ModifyUserView>();
            containerRegistry.RegisterDialog<ModifyPasswordView>();
            containerRegistry.RegisterDialog<ModifyRoleView>();
            containerRegistry.RegisterDialog<SelectUserView>();
            containerRegistry.RegisterDialog<SelectRoleView>();
            containerRegistry.RegisterDialog<ModifyDeviceView>();
            containerRegistry.RegisterDialog<ModifyAutoView>();
            containerRegistry.RegisterDialog<ModifyRechargeView>();
            containerRegistry.RegisterDialog<PrintView>();
        }
    }

}
